<?php
// Displays the colors of the product
function displayColors($colors) {
    $output = "";
    foreach($colors as $i=>$color) $output.= ($i>0?', ':'').'<span class="color-piece" style="background:#'.$color->hex.'"></span>'.CHtml::encode($color->name);

    return $output;
}

// Displays the networks of the product
function displayNetworks($networks) {
    $output = "";
    foreach($networks as $i=>$network) $output.= ($i>0?', ':'').CHtml::encode($network->name);

    return $output;
}

// Displays the Input/Output of the product
function displayIos($ios) {
    $output = "";
    foreach($ios as $i=>$io) $output.= ($i>0?', ':'').CHtml::encode($io->name);

    return $output;
}

// Displays the languages of the product
function displayLanguages($languages) {
    $output = "";
    foreach($languages as $i=>$language) $output.= ($i>0?', ':'').CHtml::encode($language->name);

    return $output;
}

?>

<?php

    // breadcrumbs
    $this->breadcrumbs=array(
        'Products'=>array('index'),
        $model->name,
    );

?>

<div class="page-header">
    <?php echo CHtml::link('<i class="icon-cog icon-white"></i> Manage Products', array('product/index'), array('class'=>'btn btn-primary')) ?>
    <h2>View Product: <em><?php echo $model->name; ?></em></h2>
</div>

<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
    'cssFile'=>Yii::app()->baseUrl.'/css/admin/detailview/styles.css',
	'attributes'=>array(
		'id',
		'category_id',
		'os_id',
		'name',
		'model',
        array(               // related colors
            'label'=>$model->getAttributeLabel('colors'),
            'type'=>'raw',
            'value'=>displayColors($model->colors),
        ),
		'chip',
		'size',
		'weight',
		'display',
		'storage',
		'memory',
		'sensors',
		array(               // related networks
            'label'=>$model->getAttributeLabel('networks'),
            'type'=>'raw',
            'value'=>displayNetworks($model->networks),
        ),
		'camera',
		'battery',
		'power',
		'audio',
		'video',
        array(               // related ios
            'label'=>$model->getAttributeLabel('ios'),
            'type'=>'raw',
            'value'=>displayNetworks($model->ios),
        ),
        array(               // related languages
            'label'=>$model->getAttributeLabel('languages'),
            'type'=>'raw',
            'value'=>displayNetworks($model->languages),
        ),
		'extra',
		'picture',
		'details',
	),
)); ?>
